package polymorphic;

//instanceof是可以判断某个对象是什么类,正确返回true,否则报错,用if判断就不执行
public class Instanceof {
    public static void main(String[] args) {
        Student s = new Student();
        go(s);//学生
    }
    public static void go(People p) {
        if (p instanceof Student) {
            System.out.println("学生");
        }
        if (p instanceof Teacher) {
            System.out.println("老师");
        }
    }

}
